package com.controller.ipother;

import org.lucksyc.utilindependent.resultview.core.data.ViewData;
import org.lucksyc.utilindependent.resultview.seed.deal.ViewBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.upper.service.ipother.IpOtherInterface;

/**
 * @author wsq
 */
@Controller
@RequestMapping("/ipother")
public class IpOtherController {
	private static final Logger log = LoggerFactory.getLogger(IpOtherController.class);
	
	@Autowired
	ViewBuilder viewBuilder;
	
	@Autowired
	IpOtherInterface ipOtherInterface;
	
	@ResponseBody
	@GetMapping("/getComputerList")
	public ViewData getComputerList() {
		log.debug("getComputerList.");
		try {
			return ipOtherInterface.getComputerList();
		} catch (Exception e) {
			log.info("getComputerList:"+e.getMessage());
		}
		return viewBuilder.failed();
	}
	
	@ResponseBody
	@GetMapping("/saveComputer")
	public ViewData saveComputer(String id,String name, String tag, String ip) {
		log.debug("saveComputer.");
		try {
			return ipOtherInterface.saveComputer(id, name, tag, ip);
		} catch (Exception e) {
//			e.printStackTrace();
			log.info("saveComputer:"+e.getMessage());
		}
		return viewBuilder.failed();
	}
	
	@ResponseBody
	@GetMapping("/delComputer")
	public ViewData delComputer(String id) {
		log.debug("delComputer.");
		try {
			return ipOtherInterface.delComputer(id);
		} catch (Exception e) {
//			e.printStackTrace();
			log.info("delComputer:"+e.getMessage());
		}
		return viewBuilder.failed();
	}
}
